package com.fh.controller;

import com.fh.dto.User;
import com.fh.mapper.UserMapper;
import com.fh.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author whf
 * @date 2024年01月09日 15:08
 */
@RequestMapping("user")
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @Autowired
    private UserMapper userMapper;

    @RequestMapping("save")
    public String save(@RequestBody User user){
        userService.save(user);
        return "成功";
    }

    @RequestMapping("query")
    public List<User> query(){
        return userMapper.selectList(null);
    }

    @RequestMapping("del")
    public String del(@RequestBody User user){
        userService.removeById(user.getId());
        return "成功";
    }

    @RequestMapping("update")
    public String update(@RequestBody User user){
        userService.updateById(user);
        return "成功";
    }


}
